// ITI1120 (Fall 2012), Lab 3, Exercice 3
// Name: Grace Hopper, Student Number: 1234567
// Description: Determines whether a number is divisible by 2/3 

import java.util.Scanner ;

class Lab3Ex3V1 
{
  /**
   * This method determines whether a number is divisible by 2/3 
   */
  public static void main (String[] args)
  { 

    //Configuration for obtaining keyboard input
    //You can delete these lines if you use
    //the class IIT1120 to make the entry
    Scanner keyboard = new Scanner(System.in); 
    // Declaration variable to read inputs into
    int integer;  // an integer
    int divisibleby2by3;  // 0 - not divisible, 1 - by 2 or 3, 2 - by 2 and 3
    // Print Identification Information
    System.out.println();
    System.out.println("ITI1120 (F-2012), Lab 3, Exercice 4");
    System.out.println("Name: Grace Hopper, Student #: 1234567");
    System.out.println("Assistant to the teaching: YourTA");      
    System.out.println();
    // Read The Input Values
    System.out.print("Enter an integer: ");
    integer = keyboard.nextInt();
    //Call to the method of solve the problem
    divisibleby2by3 = isDivisibleBy2By3(integer);
    // Display results to the screen
    if(divisibleby2by3 == 0)
    {
      System.out.println("The integer "+integer+" is not divisible by 2 or by 3");
    }
    else { /* Nothing to do */ 
    }
    if(divisibleby2by3 == 1)
    {
      System.out.println("The integer "+integer+" is divisible by 2 or by 3");  
    }
    else { /* Nothing to do */ }
    if(divisibleby2by3 == 2)
    {
      System.out.println("The integer "+integer+" is divisible by 2    and by 3");  
    }
    else { /* Nothing to do */ }
  }
  
  /**
   * Description: Determine whether entry is divisible by 2      
   * and/or 2  
   * Parameters (Input): integer - integer to be analyzed
   */
  public static int isDivisibleBy2By3(int integer)
  {
    // Declaration of variable for result 
    int divisible; // 0 - not divisible, 1 - by 2 or 3, 2 - by 2 and 3
    //  Declaration of intermediate variables
    // 
    divisible = 0;  // not divisible
    // Tests whether 2 and/or three divides
    if(integer%2==0 || integer%3==0)
    {
      divisible = 1;
    }
    else
    {
      /*  Nothing to do  */ ;
    }
    if(integer%2==0 && integer%3==0)
    {
      divisible = 2;
    }
    else
    {
      /*  Nothing to do */ ;
    }
    // Return The Result
    return(divisible);
  }
}

